﻿<div class="span10">
	<h1>Permissões do Usuário</h1>
	<?php echo Flash::render(); ?>
	<h2 style="text-align:center">Usuário: <?php echo $usuario->usuario; ?></h2>
	<script>
	$(document).ready(function(){
		$('#permissoesSelecioneTodos').click(function(){
			check = this;
			jQuery.each($('.permissao'), function(){
				check.checked ? this.checked = true : this.checked = false;
			});
		});
	});
	</script>
	<?php echo Form::open('usuario/permissoes/'.$usuario->id, array('class' => 'well')); ?>
	<table class="table table-bordered">
	<thead>
		<tr>
			<th><input type="checkbox" id="permissoesSelecioneTodos"></th>
			<th>Permissão</th>
			<th>Controlador</th>
			<th>Ação</th>
		</tr>
	</thead>
	<tbody>
	<?php foreach($permissoes as $permissao): ?>
		<tr>
			<td><input type="checkbox" name="permissoes[]" <?php echo $usuario->has('permissoes', $permissao) ? 'checked="ckecked"': '';?> class="permissao" value="<?php echo $permissao->id; ?>"></td>
			<td><?php echo $permissao->descricao; ?></td>
			<td><?php echo $permissao->controlador; ?></td>
			<td><?php echo $permissao->acao; ?></td>
		</tr>
	<?php endforeach; ?>
	</tbody>
	</table>
	<button type="submit" name="adicionarPermissao" class="btn btn-primary">Salvar</button>
	<?php echo Form::close(); ?>
</div>